import request from '@/utils/request'

export function getTargetUsableList(query) {
  let baseUrl = "/sale/target"
  if(query != undefined){
    if(typeof query == "object"){
      console.log(query)
      if(query.hasOwnProperty('targetID')){
        query['targetID'] = parseInt(query['targetID'])
        if(isNaN(query['targetID']) == false){
          baseUrl = baseUrl+"-"+query['targetID']
        }
      }
    }
  }
  return request({
    url: baseUrl,
    method: 'get'
  })
}

export function getTargetList(query) {
  return request({
    url: '/sale/admin/target/getList',
    method: 'post',
    data: query
  })
}
export function saveTarget(query) {
  return request({
    url: '/sale/admin/target/save',
    method: 'post',
    data: query
  })
}

export function removeTarget(query) {
  return request({
    url: '/sale/admin/target/remove',
    method: 'post',
    data: query
  })
}
export function getTargetDetail(query) {
  if(query != undefined){
    query = JSON.parse(JSON.stringify(query))
  }
  return request({
    url: '/sale/admin/target/info/0',
    method: 'get',
    data: query
  })
}